<template>
  <div class="UserDevice">
    <div class="title">
      <span>用户设备挂接设置</span>
      <div tabindex="0" class="icon" @click="closeDialog">×</div>
    </div>
    <div class="content">
      <div class="userDeviceContent">
        <div class="item"><span>户号：</span> <input type="text" v-model="userAccount"/></div>
      </div>
      <div class="btnGroup">
        <button @click="saveAccount">保存</button>
        <button @click="closeDialog">取消</button>
      </div>
    </div>
  </div>
</template>

<script>
import {addUserMeterInfo}from "@/api/EquipmentManagement";
export default {
  name: "UserDevicePop",
  data() {
    return {
      detailDataPopList: {},
      detailDataContent:{},
      userAccount:'',
      keywords:'',
    };
  },
  mounted() {},
  methods: {
    saveAccount(){
      this.detailDataPopList =this.$store.state.detailDataPopList;
      console.log(this.detailDataPopList,"detailDataPopList用户设备挂接")
      this.detailDataPopList.rec.forEach((item) => {
        this.detailDataContent[item.fldname] = item.fldval;
      });
      this.keywords = this.detailDataContent.keywords;
      let params={
        meterKeywords:this.keywords,
        customerId:this.userAccount,
      
      }
      addUserMeterInfo(params).then(res=>{
        if(res.code==200){
          this.$message({
            type: "success",
            message: res.message,
          });
          // this.$store.commit("setIsUserDeviceSonShow", false); 
        }else{
          this.$message({
            type: "error",
            message: res.message,
          });
        }
      console.log(res,"用户设备挂接上传")
      })
    },
    closeDialog() {
      this.$store.commit("setIsUserDeviceSonShow", false);
    },
  },
};
</script>
<style lang="scss" scoped>
.UserDevice {
  width: 25rem;
  height: 10rem;
  background: #fff;
  position: absolute;
  top: 12rem;
  left: -40rem;
  border: 1px solid #ccc;
  .title {
    width: 100%;
    height: 20%;
    background: #285383;
    display: flex;
    align-items: center;
    justify-content: space-between;
    span {
      font-size: 1rem;
      font-weight: 700;
    }
    .icon {
      cursor: pointer;
      width: 20px; /* 小方框的宽度 */
      height: 20px; /* 小方框的高度 */
      // border: 1px solid #4998f2; /* 小方框的边框 */
      margin-left: 5px; /* 小方框之间的间距 */
    }
    .icon:hover {
      color: #4998f2;
    }
    .icon:focus {
      color: #4998f2;
    }
  }
  .content {
    width: 100%;
    height: 50%;
    .userDeviceContent {
      width: 100%;
      height: 90%;
      .item {
        display: flex;
        justify-content: center;
        align-items: center;
        span {
          font-size: 1.5rem;
          color: #000;
        }
        input{
          height: 1.3rem;
        }
        }
    }
    .btnGroup {
      display: flex;
      justify-content: space-evenly;
      button {
        width: 4rem;
        height: 1.5rem;
      }
    }
  }
}
</style>
